package com.richie696.catalina;

import java.io.IOException;

public abstract class HttpServlet implements Servlet {

    @Override
    public void init() throws Exception {
    }

    @Override
    public void doPut(HttpServletRequest request, HttpServletResponse response) throws IOException {
    }

    @Override
    public void doDelete(HttpServletRequest request, HttpServletResponse response) throws IOException {
    }

    @Override
    public void doHead(HttpServletRequest request, HttpServletResponse response) throws IOException {
    }

    @Override
    public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
    }

    @Override
    public void doPost(HttpServletRequest request,HttpServletResponse response) throws IOException {
    }

    @Override
    public void service(HttpServletRequest request, HttpServletResponse response) throws Exception {
        switch (request.getRequestMethod()) {
            case GET -> doGet(request, response);
            case POST -> doPost(request, response);
            case PUT -> doPut(request, response);
            case DELETE -> doDelete(request, response);
            default -> doHead(request, response);
        }
    }

    @Override
    public void destroy() throws Exception {
    }
}
